import * as Router from 'koa-router';
// import { IRouterContext } from '../core/IRouterContext';
import { IRouterContext } from 'koa-router';
import ckService from '../service/CkService';
const motorCtr: Router = require('koa-router')();
motorCtr.prefix('/api')
import loginUtil from './../core/LoginUtils';

//2.2销售出库查询
//2.2.1需求描述:PDA扫描送货单条形码显示待出库明细。
//2.2.2接口定义:NC系统提供出库明细查询接口，由PDA系统调用。

/**
 * NC
 * 参数:billcode   >单据编号  XC1311180010
 */
motorCtr.post('/motor/queryOutStoreBill', async (ctx: IRouterContext, next: any) => {
   console.log('进入销售出库查询接口');
//    console.log('request:' + JSON.stringify(ctx.request.body));
    let rq: any = ctx.request
    let data = rq.body;
   console.log('request:' + JSON.stringify(data));

   let authorization :any = ctx.header.authorization;
   let result = await ckService.queryOutStoreBill(data,authorization);

   ctx.status = 200;
   ctx.body = result;

   console.log('response:' + JSON.stringify(result));

   await next()
})

/**
 * 销售出库签字
 */
motorCtr.post('/motor/WriteBackOutBill', async (ctx: IRouterContext, next: any) => {
   console.log('进入销售出库签字接口');
//    console.log('request:' + JSON.stringify(ctx.request.body));
    let rq: any = ctx.request
    let data = rq.body;
    console.log('request:' + JSON.stringify(data));

   let authorization :any = ctx.header.authorization;
   let result = await ckService.WriteBackOutBill(data,authorization);

   ctx.status = 200;
   ctx.body = result;

   console.log('response:' + JSON.stringify(result));

   await next()
})


export default motorCtr;